yum install -y libtool patch make gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel  gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel  krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano gettext gettext-devel ncurses-devel gmp-devel unzip libtidy-devel


rpm -ivh http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm
yum install -y libmcrypt libmcrypt-devel
mkdir -pv /opt/install
cd /opt/install
wget  http://fastlnmp.googlecode.com/files/php-5.2.14.tar.gz
wget  http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz 

phpbin=php-5.2.14.tar.gz

if [ -f "$phpbin" ] 
then
 tar xzf $phpbin
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz |patch -d php-5.2.14 -p1
cd php-5.2.14
./configure --enable-fastcgi --prefix=/usr/local/php5  --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-mysql --with-mysqli --with-pdo-mysql --enable-sockets --with-curl --with-ttf --with-libxml-dir --with-config-file-path=/usr/local/php5/etc --with-zlib --enable-exif --enable-ftp --with-xmlrpc --enable-zip --with-iconv-dir --with-libxml-dir --with-mcrypt --with-tidy=/usr --enable-fpm --enable-force-cgi-redirect --with-jpeg-dir=/usr --with-libdir=lib64
make -j 8
make install
fi
cp sapi/cgi/fpm/php-fpm /etc/init.d/ -v
chmod +x /etc/init.d/php-fpm -v
cp  php.ini-recommended /usr/local/php5/etc/php.ini -v
echo "############################################################"
echo "please edit etc/php-fpm"
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on 

wget  http://acalnmp52.googlecode.com/svn/ZendOptimizer.so
mv -v ZendOptimizer.so /opt/install
echo "zend_extension=/opt/install/ZendOptimizer.so" >> /usr/local/php5/etc/php.ini

wget http://acalnmp52.googlecode.com/svn/userkey.zl
mv userkey.zl /opt/install
echo "zend_optimizer.license_path=/opt/install/userkey.zl" >> /usr/local/php5/etc/php.ini

mkdir -pv /data/httpd
echo "<?php phpinfo(); "> /data/httpd/i.php